﻿CREATE TABLE [dbo].[InstrumentAlias] (
    [Id]         INT           IDENTITY (100, 1) NOT NULL,
    [Version]    ROWVERSION    NOT NULL,
    [ModifiedBy] INT           NOT NULL,
    [ModifiedDt] DATETIME      NOT NULL,

	[InstrumentId]	INT        NULL CONSTRAINT [FK_InstrumentAliasInstrument] FOREIGN KEY ([InstrumentId]) REFERENCES [dbo].[Instrument] ([Id]),
    [Type]			VARCHAR (255) NOT NULL,
	[Alias]			VARCHAR (255) NOT NULL,

    CONSTRAINT [PK_InstrumentAlias] PRIMARY KEY CLUSTERED ([Id] ASC)	
);
GO

--Indexes:
CREATE NONCLUSTERED INDEX [UX_InstrumentAlias_TypeAlias]
    ON [dbo].[InstrumentAlias]([Type], [Alias]);
GO

CREATE NONCLUSTERED INDEX [UX_InstrumentAlias_InstrumentIdType]
    ON [dbo].[InstrumentAlias]([InstrumentId], [Type]);
